<template>
    <a-form ref='formRef' :label-col='{span : 5}' :model='formData'>
        <a-form-item style='display:none' name='id'>
            <a-input type='hidden' v-model:value='formData.id' />
        </a-form-item>
        <a-form-item label='精彩回顾' name='history'>
            <RichEditor v-model="formData.history" :upload-api="uploadApi" />
        </a-form-item>
    </a-form>
</template>

<script lang="ts" setup>
    import RichEditor from '@/components/RichEditor.vue'
        import { ref } from 'vue';
import { uploadApi } from "@/api/Upload";
import { saveApi } from '@/api/Yunxin';

    const props = defineProps<{
        row? : any;
    }>()


    const formRef = ref()

    
    const formData = ref<any>({
        id : 0,
        history: '',
    })

    if(props.row) {
        for(let k in props.row) {
            if(k in formData.value) {
                formData.value[k] = props.row[k]
            }
        }

        
    }

    async function submit() {
        let params  = await formRef.value.validate()
        return saveApi(params)
    }


    
    defineExpose({
        submit
    })
</script>